#!/usr/bin/env python
# -*- coding: utf8 -*-

from django import forms
from django.contrib.auth.models import User
from accounts.models import UserProfile
class UserForm(forms.ModelForm):
    class Meta:
        model = User
        fields = ('username', 'password')

    def save(self, commit=True):
        user = super(UserForm, self).save(commit=False)
        user.set_password(self.cleaned_data['password'])
        if commit==True:
            user.save()
        return user

class UserProfileForm(forms.ModelForm):
    class Meta:
        model = UserProfile
        exclude = ('user', )


